import request from '@/utils/request'
import axios from 'axios'

/**
 * 获取歌曲列表
 */
export const getSongListApi = (params) => request.get('/song/page', { params })

/**
 * 新增或修改歌曲
 */
export const saveOrUpdateSongApi = (data) => request.post('/song', data)

/**
 * 批量删除歌曲
 */
export const deleteSongApi = (ids) =>
  request.delete('/song/del/batch', { data: ids })

/**
 * 根据关键词获取歌词信息
 */
export const getLyricApi = (params) => request.get('/song/lyric', { params })

/**
 * 爬取歌词信息
 *
 * @param {*} maxResult 最大结果数
 * @param {*} keyword 关键词
 */
export const getLyricFromNetApi = (maxResult, keyword) =>
  axios.get(`http://127.0.0.1:37808/0/${maxResult}/${keyword}`)

/**
 * 根据id获取歌曲信息
 */
export const getSongByIdApi = (id) => request.get(`/song/${id}`)

/**
 * 通过id通过歌曲
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const passSongApi = (id) => request.get(`/song/pass/${id}`)

/**
 * 拒绝通过歌曲
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const rejectSongApi = (data) => request.put(`/song/reject`, data)

/**
 * 举报歌曲
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const reportSongApi = (id) => request.get(`/song/report/${id}`)
